/**
 * @project name:mail
 */
package com.situ.mail.shop.controller;

import com.situ.mail.shop.pojo.User;
import com.situ.mail.shop.service.UserService;
import com.situ.mail.utils.ConfigUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author : yun&bo
 * @CreateDate : ==>2020/12/23 15:38
 * @ClassName : ==>
 * @Description : ==>
 * @Version
 */
@RestController
@RequestMapping("login/login/")
public class AdminController {

    private UserService userService;

    public AdminController(UserService userService) {
        this.userService = userService;
    }

    private static final String LOGIN_ADMIN = "admin/login_admin";
    private static final String INDEX_ADMIN = "admin/index_admin";

    @RequestMapping("admin")
    public ModelAndView adminLogin(ModelAndView modelAndView) {
        modelAndView.setViewName(LOGIN_ADMIN);
        return modelAndView;
    }

    @RequestMapping("do_login_admin")
    public ModelAndView adminDoLogin(User user, ModelAndView modelAndView) {
        modelAndView.setViewName(INDEX_ADMIN);
        return modelAndView;
    }


    @RequestMapping("outAdminLogin")
    public ModelAndView adminDoOutLogin(User user, ModelAndView modelAndView, HttpServletRequest req) {
        req.getSession().removeAttribute(ConfigUtil.SESSION_LOGIN_ADMIN_NAME);
        modelAndView.setViewName(LOGIN_ADMIN);
        return modelAndView;
    }


}
